package yz.com.javautil.monitor;

import org.apache.commons.io.monitor.FileAlterationListener;
import org.apache.commons.io.monitor.FileAlterationObserver;

import java.io.File;

/**
 * @author Administrator
 */
public class PushFileAlterationListener implements FileAlterationListener {

    private String rootPath;

    public PushFileAlterationListener(String rootPath) {
        this.rootPath = rootPath;
    }

    @Override
    public void onDirectoryChange(File file) {
    }

    @Override
    public void onDirectoryCreate(File file) {

        System.out.println("Directory create: " + file.getAbsolutePath() + "  " + file.getParent());
    }

    @Override
    public void onDirectoryDelete(File file) {

        System.out.println("Directory delete: " + file.getAbsolutePath() + "  " + file.getParent());
    }

    @Override
    public void onFileChange(File file) {

        System.out.println("File change: " + file.getAbsolutePath() + "  " + file.getParent());
    }

    @Override
    public void onFileCreate(File file) {

        System.out.println("File created: " + file.getAbsolutePath() + "  " + file.getParent());
    }

    @Override
    public void onFileDelete(File file) {

        System.out.println("File deleted: " + file.getAbsolutePath() + "  " + file.getParent());
    }

    @Override
    public void onStart(FileAlterationObserver filealterationobserver) {
        System.out.println("start");
    }

    @Override
    public void onStop(FileAlterationObserver filealterationobserver) {
        System.out.println("end");
    }
}
